package com.zhengbing.tj.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;

/**
 * 用户实体类
 *
 * @author zhengbing
 * @date 2025-07-07
 */
@TableName("user")
@Api(tags = "用户")
public class User extends Model<User> {
    /**
     * 用户ID
     */
    @ApiModelProperty(value = "用户ID", example = "123456789012345678")
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;
    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名", example = "张三")
    private String name;
    /**
     * 用户密码
     */
    @ApiModelProperty(value = "用户密码", example = "$2a$10$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
    private String password;
    /**
     * 用户邮箱
     */
    @ApiModelProperty(value = "用户邮箱", example = "zhangsan@example.com")
    private String email;
    
    // 无参构造函数
    public User() {
    }
    
    // 全参构造函数
    public User(Long id, String name, String password, String email) {
        this.id = id;
        this.name = name;
        this.password = password;
        this.email = email;
    }
    
    // getter和setter方法
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getPassword() {
        return password;
    }
    
    public void setPassword(String password) {
        this.password = password;
    }
    
    public String getEmail() {
        return email;
    }
    
    public void setEmail(String email) {
        this.email = email;
    }
    
    // 重写equals方法
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        
        User user = (User) o;
        
        if (id != null ? !id.equals(user.id) : user.id != null) return false;
        if (name != null ? !name.equals(user.name) : user.name != null) return false;
        if (password != null ? !password.equals(user.password) : user.password != null) return false;
        return email != null ? email.equals(user.email) : user.email == null;
    }
    
    // 重写hashCode方法
    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (password != null ? password.hashCode() : 0);
        result = 31 * result + (email != null ? email.hashCode() : 0);
        return result;
    }
}